﻿using System.Collections.Generic;
using UcAsp.Net.IDAL;
using UcAsp.Net.Model;
namespace UcAsp.Net.BLL
{
    public class UserInfoBLL
    {
        private static readonly IUserInfoDAL dal = DALFactory.DataAccess.CreateUserInfo();
        private static UserInfoBLL _userinfo;
        public static UserInfoBLL GetInstance
        {
            get
            {
                if (_userinfo == null)
                {
                    _userinfo = new UserInfoBLL();
                }
                return _userinfo;
            }
        }
        public List<UserInfo> SelectByKeyword(int pagesize, int pageindex, out int pagecount, string keyword)
        {
            return dal.SelectByKeyword(pagesize, pageindex, out pagecount, keyword);
        }
        public List<UserInfo> Select(int pagesize, int pageindex, out int pagecount)
        {
            return dal.Select(pagesize, pageindex, out pagecount);
        }
        public bool Delete(int id)
        {
            return dal.Delete(GetUserInfoByID(id));
        }
        public UserInfo Insert(UserInfo model)
        {
            return dal.Insert(model);
        }
        public bool Update(UserInfo model)
        {
            return dal.Update(model);
        }
        /// <summary>
        /// 通过id获取个人信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public UserInfo GetUserInfoByID(int id)
        {
            return dal.GetUserInfoByID(id);
        }

        public UserInfo GetUserInfoByNameAndPassword(string username, string password)
        {
            return dal.GetUserInfoByNameAndPassword(username, password);
        }
        public UserInfo GetUserInfoByNameAndOpenID(string username, string openid)
        {
            return dal.GetUserInfoByNameAndOpenID(username, openid);
        }
    }
}